import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

/**
 * All rights Reserved, Designed By www.super-master.cn
 *
 * @ProjectName: rock-paper-scissors
 * @Package: PACKAGE_NAME
 * @ClassName: windows
 * @Description: []
 * <p> </p>
 * @Author: [cai]
 * @Date: 2022/5/9 10:01
 * @Version: V1.0
 **/

public class windows  implements Runnable{


    @Override
    public void run() {

        JFrame jf = new JFrame("测试窗口");
        jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);


        JButton btn01 = new JButton("石头");
        JButton btn02 = new JButton("剪刀");
        JButton btn03 = new JButton("布");

            Box hBox01 = Box.createHorizontalBox();
        hBox01.add(btn01);
        hBox01.add(btn02);
        hBox01.add(btn03);


        Box hBox02 = Box.createHorizontalBox();
        JTextField jtf1 = new JTextField("结果");
        JTextField jtf2=new JTextField("         ");
        jtf1.setEnabled(false);
        jtf2.setEnabled(false);
        hBox02.add(jtf1);
        hBox02.add(jtf2);

        Box hBox03=Box.createHorizontalBox();
        JTextField jtf3 = new JTextField("赢：");
        JTextField jtf4=new JTextField("  ");
        JTextField jtf5 = new JTextField("平：");
        JTextField jtf6=new JTextField("  ");
        JTextField jtf7 = new JTextField("输：");
        JTextField jtf8=new JTextField("  ");
        jtf3.setEnabled(false);
        jtf4.setEnabled(false);
        jtf5.setEnabled(false);
        jtf6.setEnabled(false);
        jtf7.setEnabled(false);
        jtf8.setEnabled(false);
        hBox03.add(jtf3);
        hBox03.add(jtf4);
        hBox03.add(jtf5);
        hBox03.add(jtf6);
        hBox03.add(jtf7);
        hBox03.add(jtf8);

        Box vBox = Box.createVerticalBox();
        vBox.add(hBox01);
        vBox.add(hBox02);
        vBox.add(hBox03);

        jf.setContentPane(vBox);
        jf.pack();
        jf.setLocationRelativeTo(null);
        jf.setVisible(true);
///---------------------------------------------------------------------------//



        btn01.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //启动对局线程
                StoneScissorsCloImpl standard = new StoneScissorsCloImpl();
                Random random = new Random();
                int computer = random.nextInt(3);
                standard.gameStandard(2,computer);
                jtf2.setText(StoneScissorsCloImpl.result_view);
                jtf4.setText(String.valueOf(Result.userWin));
                jtf6.setText(String.valueOf(Result.userDraws));
                jtf8.setText(String.valueOf(Result.userLosses));
            }
        });
        btn02.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //启动对局线程
                StoneScissorsCloImpl standard = new StoneScissorsCloImpl();
                Random random = new Random();
                int computer = random.nextInt(3);
                standard.gameStandard(1,computer);
                jtf2.setText(StoneScissorsCloImpl.result_view);
                jtf4.setText(String.valueOf(Result.userWin));
                jtf6.setText(String.valueOf(Result.userDraws));
                jtf8.setText(String.valueOf(Result.userLosses));

            }
        });
        btn03.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //启动对局线程
                StoneScissorsCloImpl standard = new StoneScissorsCloImpl();
                Random random = new Random();
                int computer = random.nextInt(3);
                standard.gameStandard(3,computer);
                jtf2.setText(StoneScissorsCloImpl.result_view);
                jtf4.setText(String.valueOf(Result.userWin));
                jtf6.setText(String.valueOf(Result.userDraws));
                jtf8.setText(String.valueOf(Result.userLosses));

            }
        });
    }
}
